package com.huawei.appgallery.foundation.ui.framework.widget;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Path.Direction;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.Shader.TileMode;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.widget.ImageView;
import androidx.annotation.DimenRes;
import androidx.annotation.DrawableRes;

public class LineImageView extends ImageView {
    private final Matrix ˊ;
    private Path ˋ;
    protected Drawable ˎ;
    private Paint ˏ;
    private RectF ॱ;
    private float[] ॱॱ;

    public LineImageView(android.content.Context r11, android.util.AttributeSet r12, int r13) {
        /* JADX: method processing error */
/*
Error: java.util.NoSuchElementException
	at java.util.HashMap$HashIterator.nextNode(HashMap.java:1444)
	at java.util.HashMap$KeyIterator.next(HashMap.java:1466)
	at jadx.core.dex.visitors.blocksmaker.BlockFinallyExtract.applyRemove(BlockFinallyExtract.java:535)
	at jadx.core.dex.visitors.blocksmaker.BlockFinallyExtract.extractFinally(BlockFinallyExtract.java:175)
	at jadx.core.dex.visitors.blocksmaker.BlockFinallyExtract.processExceptionHandler(BlockFinallyExtract.java:79)
	at jadx.core.dex.visitors.blocksmaker.BlockFinallyExtract.visit(BlockFinallyExtract.java:51)
	at jadx.core.dex.visitors.DepthTraversal.visit(DepthTraversal.java:31)
	at jadx.core.dex.visitors.DepthTraversal.visit(DepthTraversal.java:17)
	at jadx.core.ProcessClass.process(ProcessClass.java:37)
	at jadx.core.ProcessClass.processDependencies(ProcessClass.java:59)
	at jadx.core.ProcessClass.process(ProcessClass.java:42)
	at jadx.api.JadxDecompiler.processClass(JadxDecompiler.java:306)
	at jadx.api.JavaClass.decompile(JavaClass.java:62)
*/
        /*
        r10 = this;
        r0 = 1;
        r1 = 0;
        r10.<init>(r11, r12, r13);
        r2 = new android.graphics.Matrix;
        r2.<init>();
        r10.ˊ = r2;
        r2 = new android.graphics.Paint;
        r2.<init>();
        r10.ˏ = r2;
        r2 = r10.ˏ;
        r2.setAntiAlias(r0);
        if (r12 == 0) goto L_0x00a4;
    L_0x001a:
        r2 = o.dky.o.ʽʽ;
        r4 = r11.obtainStyledAttributes(r12, r2, r13, r1);
        r2 = o.dky.o.ʾˊ;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = r4.hasValue(r2);	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        if (r2 == 0) goto L_0x00a5;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
    L_0x0028:
        r2 = o.dky.o.ʾˊ;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r3 = 0;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = r4.getDimensionPixelSize(r2, r3);	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r3 = r2;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
    L_0x0030:
        r2 = o.dky.o.ʿᐝ;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r5 = r4.getDimensionPixelSize(r2, r3);	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = o.dky.o.ˆ;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r6 = r4.getDimensionPixelSize(r2, r3);	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = o.dky.o.ˇ;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r7 = r4.getDimensionPixelSize(r2, r3);	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = o.dky.o.ʿˋ;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r8 = r4.getDimensionPixelSize(r2, r3);	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = o.dky.o.ʾˋ;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = r4.hasValue(r2);	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        if (r2 == 0) goto L_0x00a7;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
    L_0x0050:
        r2 = o.dky.o.ʾˋ;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = r4.getDrawable(r2);	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
    L_0x0056:
        r10.ˎ = r2;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = o.dky.o.ˈˊ;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = r4.hasValue(r2);	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        if (r2 == 0) goto L_0x00b2;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
    L_0x0060:
        r2 = o.dky.o.ˈˊ;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r9 = 0;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = r4.getBoolean(r2, r9);	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        if (r2 == 0) goto L_0x00b2;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
    L_0x0069:
        r1 = new android.graphics.Path;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r1.<init>();	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r10.ˋ = r1;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r1 = new android.graphics.RectF;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r1.<init>();	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r10.ॱ = r1;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        if (r0 == 0) goto L_0x00b4;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
    L_0x0079:
        r0 = 8;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r0 = new float[r0];	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r1 = 0;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = (float) r3;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r0[r1] = r2;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r1 = 1;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = (float) r3;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r0[r1] = r2;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r1 = 2;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = (float) r3;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r0[r1] = r2;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r1 = 3;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = (float) r3;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r0[r1] = r2;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r1 = 4;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = 0;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r0[r1] = r2;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r1 = 5;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = 0;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r0[r1] = r2;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r1 = 6;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = 0;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r0[r1] = r2;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r1 = 7;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = 0;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r0[r1] = r2;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r10.ॱॱ = r0;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
    L_0x009f:
        if (r4 == 0) goto L_0x00a4;
    L_0x00a1:
        r4.recycle();
    L_0x00a4:
        return;
    L_0x00a5:
        r3 = r1;
        goto L_0x0030;
    L_0x00a7:
        r2 = r10.getResources();	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r9 = o.dky.a.ॱॱ;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = r2.getDrawable(r9);	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        goto L_0x0056;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
    L_0x00b2:
        r0 = r1;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        goto L_0x0069;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
    L_0x00b4:
        r0 = 8;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r0 = new float[r0];	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r1 = 0;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = (float) r5;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r0[r1] = r2;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r1 = 1;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = (float) r5;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r0[r1] = r2;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r1 = 2;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = (float) r6;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r0[r1] = r2;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r1 = 3;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = (float) r6;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r0[r1] = r2;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r1 = 4;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = (float) r8;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r0[r1] = r2;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r1 = 5;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = (float) r8;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r0[r1] = r2;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r1 = 6;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = (float) r7;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r0[r1] = r2;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r1 = 7;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = (float) r7;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r0[r1] = r2;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r10.ॱॱ = r0;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        goto L_0x009f;
    L_0x00db:
        r0 = move-exception;
        r1 = "LineImageView";	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = new java.lang.StringBuilder;	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2.<init>();	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r3 = "CropRightRoundImageView init(AttributeSet attrs) ";	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r2 = r2.append(r3);	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r0 = r0.getMessage();	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r0 = r2.append(r0);	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        r0 = r0.toString();	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        o.dna.ˊ(r1, r0);	 Catch:{ RuntimeException -> 0x00db, all -> 0x00fe }
        if (r4 == 0) goto L_0x00a4;
    L_0x00fa:
        r4.recycle();
        goto L_0x00a4;
    L_0x00fe:
        r0 = move-exception;
        if (r4 == 0) goto L_0x0104;
    L_0x0101:
        r4.recycle();
    L_0x0104:
        throw r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.huawei.appgallery.foundation.ui.framework.widget.LineImageView.<init>(android.content.Context, android.util.AttributeSet, int):void");
    }

    public LineImageView(Context context) {
        this(context, null);
    }

    public LineImageView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public void setTouchEffectDrawable(@DrawableRes int i) {
        this.ˎ = getResources().getDrawable(i);
    }

    protected void dispatchDraw(Canvas canvas) {
        super.dispatchDraw(canvas);
        if (this.ˎ != null && !isInEditMode()) {
            this.ˎ.setBounds(0, 0, getWidth(), getHeight());
            this.ˎ.draw(canvas);
        }
    }

    protected void drawableStateChanged() {
        if (this.ˎ != null) {
            this.ˎ.setState(getDrawableState());
            invalidate();
        }
        super.drawableStateChanged();
    }

    protected void onDraw(Canvas canvas) {
        if (getDrawable() != null) {
            ˋ();
            this.ˋ.reset();
            this.ॱ.set(0.0f, 0.0f, (float) getWidth(), (float) getHeight());
            this.ˋ.addRoundRect(this.ॱ, this.ॱॱ, Direction.CW);
            canvas.drawPath(this.ˋ, this.ˏ);
        }
    }

    private void ˋ() {
        Drawable drawable = getDrawable();
        if (drawable != null) {
            Bitmap ˋ = ˋ(drawable);
            if (ˋ != null) {
                Shader bitmapShader = new BitmapShader(ˋ, TileMode.CLAMP, TileMode.CLAMP);
                float max = Math.max((((float) getWidth()) * 1.0f) / ((float) ˋ.getWidth()), (((float) getHeight()) * 1.0f) / ((float) ˋ.getHeight()));
                this.ˊ.setScale(max, max);
                bitmapShader.setLocalMatrix(this.ˊ);
                this.ˏ.setShader(bitmapShader);
            }
        }
    }

    private Bitmap ˋ(Drawable drawable) {
        if (drawable instanceof BitmapDrawable) {
            return ((BitmapDrawable) drawable).getBitmap();
        }
        int intrinsicWidth = drawable.getIntrinsicWidth();
        int intrinsicHeight = drawable.getIntrinsicHeight();
        if (intrinsicWidth <= 0 || intrinsicHeight <= 0) {
            return null;
        }
        Bitmap createBitmap = Bitmap.createBitmap(intrinsicWidth, intrinsicHeight, Config.ARGB_8888);
        Canvas canvas = new Canvas(createBitmap);
        drawable.setBounds(0, 0, intrinsicWidth, intrinsicHeight);
        drawable.draw(canvas);
        return createBitmap;
    }

    public int ˎ(int i) {
        return (int) TypedValue.applyDimension(1, (float) i, getResources().getDisplayMetrics());
    }

    public void setCornerRadiusDimen(@DimenRes int i) {
        float dimension = getResources().getDimension(i);
        this.ॱॱ = new float[]{dimension, dimension, dimension, dimension, dimension, dimension, dimension, dimension};
        invalidate();
    }

    public void setBorderRadius(int i) {
        int ˎ = ˎ(i);
        this.ॱॱ = new float[]{(float) ˎ, (float) ˎ, (float) ˎ, (float) ˎ, (float) ˎ, (float) ˎ, (float) ˎ, (float) ˎ};
        invalidate();
    }
}
